import uploadLink from './impl/upload_instance'
import {Toast} from 'vant'
import {BizError} from '../exception/exceptions'


export function upload (url, data) {
  return uploadLink(url, data).then(res => res.data || {})
}

function uploaderImage (data) {
  return upload('https://api.zhiyecn.com/FileUploadServlet?web=h5', data).then(result => {
      if (result.resultCode === '000000') {
        return Promise.resolve(result)
      }else{
        Toast(result.errorInfo)
        return Promise.reject(new BizError(result))
      }
    }
  )
}

export default uploaderImage

